/*
 * @Description: 
 * @Author: ouyaping
 * @Date: 2023-04-11 14:20:44
 * @LastEditors: ouyaping
 * @LastEditTime: 2023-04-12 17:49:04
 */
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';
import { join } from 'path';

async function bootstrap() {
  // const app = await NestFactory.create(AppModule, { cors: true });
  // await app.listen(50051);

  const app = await NestFactory.create(AppModule, { cors: true });
  app.connectMicroservice<MicroserviceOptions>({
    transport: Transport.GRPC,
    options: {
      url: "0.0.0.0:50051",
      package: 'va600.client',
      protoPath: join(__dirname, "../protobufs/client.proto"),
      loader: {
        arrays: true,
        keepCase: true,
        longs: String,
        enums: String,
        defaults: true,
        oneofs: true
      }
    }
  });

  await app.startAllMicroservices();
  await app.listen(3001);
  console.log(`Application is running on: ${await app.getUrl()}`);
  
}
bootstrap();
